﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity;

namespace SampleApplication.Models
{
    class SampleDatabaseInitializer : CreateDatabaseIfNotExists<SampleContext>
    {
        protected override void Seed(SampleContext context)
        {
            base.Seed(context);
            var r = new Random();
            var baseTime = new DateTime(1950, 1, 1);
            foreach (var p in Enumerable.Range(1, 1000).Select(i => new Person 
                { 
                    Name = "田中　太郎" + i,
                    Birthday = baseTime + TimeSpan.FromDays(r.Next(365 * 60))
                }))
            {
                context.People.Add(p);
            }
        }
    }
}
